package com.mobiletrain.org.motherkitch.fenlei.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import com.lidroid.xutils.BitmapUtils;
import com.mobiletrain.org.motherkitch.R;
import com.mobiletrain.org.motherkitch.fenlei.bean.Reply;
import com.mobiletrain.org.motherkitch.utils.ImageLoad;

import java.util.ArrayList;

/**
 * Created by aaa on 15-4-28.
 */
public class ThirdList3Adapter extends BaseAdapter {
    private final BitmapUtils bitmap;
    private Context context;
    private ArrayList<Reply>arrays;

    public ThirdList3Adapter(Context context, ArrayList<Reply> arrays) {
        this.context = context;
        this.arrays = arrays;
        bitmap=ImageLoad.getBitmapUtils(context);
    }

    @Override
    public int getCount() {
        if(arrays!=null){
            return arrays.size();
        }
        return 0;
    }

    @Override
    public Object getItem(int position) {
        return arrays.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        MyHoder5 hoder5=null;
        if(convertView==null){
            convertView= LayoutInflater.from(context).inflate(R.layout.third_list3_item,null);
            hoder5=new MyHoder5();
            hoder5.tou= (ImageView) convertView.findViewById(R.id.third_list3_tou);
            hoder5.name= (TextView) convertView.findViewById(R.id.third_list3_name);
            hoder5.time= (TextView) convertView.findViewById(R.id.third_list3_time);
            hoder5.year= (TextView) convertView.findViewById(R.id.third_list3_year);
            hoder5.content= (TextView) convertView.findViewById(R.id.third_list3_content);
            convertView.setTag(hoder5);
        }else{
            hoder5= (MyHoder5) convertView.getTag();
        }
        Reply reply=arrays.get(position);
        bitmap.display(hoder5.tou,reply.getAvatar());
        hoder5.name.setText(reply.getNickname());
        hoder5.time.setText(reply.getShow_date());
        hoder5.year.setText(reply.getAge_str());
        hoder5.content.setText(reply.getContent());

        return convertView;
    }
    class  MyHoder5{
        ImageView tou;
        TextView name;
        TextView time;
        TextView year;
        TextView content;
    }
}
